package com.zy.qudadid.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zy.lcpassenger.R;
import com.zy.qudadid.model.NearCar;
import com.zy.qudadid.presenter.IndexNearPresenter;
import com.zy.qudadid.ui.adapter.base.BaseAdapter;
import com.zy.qudadid.ui.widget.CustomImageView;
import com.zy.qudadid.utils.StringUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ninos on 2016/9/20.
 */
public class IndexNearAdapter extends BaseAdapter<IndexNearAdapter.VHolder, NearCar, IndexNearPresenter> {

    public IndexNearAdapter(Context context, IndexNearPresenter indexNearPresenter, View header) {
        super(context, indexNearPresenter, header);
        isAddFooter = false;
    }

    public IndexNearAdapter(Context context, IndexNearPresenter indexNearPresenter) {
        super(context, indexNearPresenter);
        isAddFooter = false;
    }

    @Override
    public int provideItemLayoutId() {
        return R.layout.activity_index_near_item;
    }

    @Override
    public VHolder createVH(ViewGroup parent, int viewType, View view) {
        return new VHolder(view);
    }

    @Override
    public void bindData(VHolder holder, final int position) {
        NearCar passenger = data.get(position);

        Glide.with(context)
                .load(passenger.user_avatar)
                .fitCenter()
                .crossFade()
                .placeholder(R.drawable.adm)
                .into(holder.ini_img);

        holder.ini_name.setText(StringUtil.isEmpty(passenger.realname)?"未命名":passenger.realname);
        holder.ini_phone.setText("电话："+passenger.driver_mobile);
        holder.ini_rote.setText(""+passenger.EWai.juli+"公里");

    }

    class VHolder extends RecyclerView.ViewHolder {

        @Nullable @Bind(R.id.ini_img)CustomImageView ini_img;
        @Nullable @Bind(R.id.ini_name)TextView ini_name;
        @Nullable @Bind(R.id.ini_phone)TextView ini_phone;
        @Nullable @Bind(R.id.ini_rote)TextView ini_rote;

        VHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }


}